Repository navigation
refactor(codegen-kotlin): move Exposed, relations, repository and extract generators onto KotlinWriter - #659
Merged
Merged
Conversation
The Exposed table generator (the table object and its seven per-package support files), the relation helpers, the repository base and the extract mirror now write through KotlinWriter (ADR-0063) and no longer import KotlinPoet; they read the type mapper's KotlinPoet types by qualified name until W-KT-4 retires it. Their four entries leave the layout ratchet's allowlist. Generated output changes in layout only: sorted imports, no blank line at the start of a body or the end of a support file, a short parameter list on one line, a long KDoc as a block, a blank line after a header comment. The snapshot goldens are refreshed to match. KotlinWriter now imports a root-package name into a file in a named package, as the replaced generators did; a new kotlin writer case pins it.
…ount in docs/ports/kotlin.md replaced with a pointer to ADR-0063 and the ratchet allowlist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
KotlinExposedTableGenerator,KotlinRelationsGenerator,KotlinRepositoryGeneratorandKotlinExtractSchemaEmitterontoKotlinWriter(ADR-0063) and drops their own KotlinPoet layout. Their four entries leave the codegen-kotlin layout-ratchet allowlist.KotlinNamingstays listed because ejected copies still callpackageHeader.KotlinWriter.needsImportnow imports a dotless (root-package) name unless the file is itself in the root package. The replaced generators relied on this import, and dropping it would break compilation. Adds twokotlin-imports-root-package*writer-conformance cases (a named-package file imports the name; a root-package file does not) and aspec/code-writer.mdline; the writer-conformance case count moves 86 to 88.Evidence
Every golden diff is layout only. The 17 changed snapshot files show only: imports in one sorted group, no blank line at the start of a class or companion body, no trailing blank line at the end of a support file, a one-property extract mirror on one line, an over-long one-line KDoc written as a block, and a blank line after the extract mirror's header comment. The repository
@autoSetKDoc keeps its hanging indent. The pipeline's review compared the seven support-file bodies against the old builders, whitespace-normalised, and found them identical.Suites run locally on this change before the gate (these are the live evidence for the change; the gate's Test step recorded "no live scenario driven", and the operator accepted these runs in its place):
codegen-kotlinfull suite (snapshot goldens,CodegenCompileConformanceTestcompile gate,EjectedAtBaseGeneratorsCompatTest, writer conformance, layout ratchet)codegen-kotlin-exposed1x-check(Exposed 1.x compile + round trip against Testcontainers Postgres)integration-tests-kotlin(Exposed 0.x persistence corpus + generated api-contract lanes against Testcontainers Postgres)scripts/ci-local.sh --only gatesThe gate's own Test command (
scripts/ci-local.sh --affected --strict-toolchains, every port lane) passed. The second root-package case was added by the gate's fix round after review.no-mistakes: 1 run (outcome
passed-with-override: the Test step's "no live run" verdict was approved by the operator on the evidence above).Validation
Risk Assessment
✅ Low: A mechanical port onto KotlinWriter whose support-file text matches the old builders line for line, whose import sets match for both Exposed APIs, and whose one writer behaviour change, the root-package import, keeps the imports the old generators wrote; the only finding is a missing negative conformance case.
Testing
Ran the Kotlin and core writer conformance corpora through their test runners (44 and 40 cases, all passing). These cover the root-package import rule. None of the scenarios were driven live: the Kotlin root-package import case and the core engine case are unit-level conformance results, and the four converted generators' output was not generated from a fixture and checked. The layout-only claim is therefore unverified by live run. Verdict inconclusive; open item is whether a live generate run is required.
Evidence: Writer conformance surefire reports (Kotlin 44/0, core 40/0)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - 1 info, resolved
fixtures/writer-conformance/cases/kotlin-imports-root-package.json:2- The new writer case's description claims two behaviours: a file in a named package imports a dotless (root-package) name, and a file in the root package does not. Only the first is exercised; the root-package side of KotlinWriter.needsImport (pkg == "" && packageName empty -> no line) has no case, so a later 'always import dotless names' simplification would pass this fixture. Add a sibling case (nopackageop, orpackage "") expecting justval t = RootTablewith no import line (oracle: Kotlin spec, a root-package name is visible unqualified in another root-package file).✅ Resolved: the gate's fix round added
fixtures/writer-conformance/cases/kotlin-imports-root-package-same-file.json(a root-package file writesval t = RootTablewith no import line) and moved the writer-conformance count to 88 (12 Kotlin);KotlinWriterConformanceTest44/0.✅ **Test** - passed with operator-approved exception (2 "no live run" warnings)
scripts/ci-local.sh --affected --strict-toolchainsmvn -o -q -pl codegen-kotlin -am test -Dtest='KotlinWriterConformanceTest,*Exposed*,*Relations*,*Repository*,*ExtractSchema*' -Dsurefire.failIfNoSpecifiedTests=falsein server/java (exit 0)Surefire report summary in server/java/codegen-kotlin/target/surefire-reports: 713 tests, 0 failures, 0 errors (count matches the baseline in the intent; the report dir may include prior runs)Read fixtures/writer-conformance/cases/kotlin-imports-root-package.json (root-package import case pinned by KotlinWriterConformanceTest)🔧 Fix applied (review-1).
✅ Resolved by operator decision: the two "no live run" warnings below were approved as a Test exception on the local evidence listed under Evidence above (codegen-kotlin 714/0, Exposed 1.x Postgres round trip 5/0, integration-tests-kotlin 462/0).
scripts/ci-local.sh --affected --strict-toolchainsConfirmed review-1 fix present: fixtures/writer-conformance/cases/kotlin-imports-root-package-same-file.json exists and docs/CONFORMANCE.md reads 88 cases (12 Kotlin).mvn -q -o -pl codegen-kotlin -am -Dtest=KotlinWriterConformanceTest,WriterConformanceTest testin server/java: exit 0, KotlinWriterConformanceTest 44 run / 0 failures, WriterConformanceTest 40 run / 0 failures.Baselinescripts/ci-local.sh --affected --strict-toolchainsalready passed at target commit; no source or test files changed in this turn, so no re-run.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.